//
//  LoanFeeHeadView.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/12/17.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class LoanFeeHeadView: UIView {

    fileprivate let interestLabel = UILabel() //利率
    fileprivate let managementLabel = UILabel() //管理费
    fileprivate let onceLabel = UILabel() //一次性费用
    
    init(frame:CGRect,model:GenericLoansModel) {
        super.init(frame: frame)
        
        interestLabel.text = model.rate_unit! + interestRates + model.interest_rate! + "%"
        interestLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        self.addSubview(interestLabel)
        
        managementLabel.textAlignment = .center
        managementLabel.text = managementFee + model.management_fee! + "%"
        managementLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        self.addSubview(managementLabel)
        
        onceLabel.text = onceFee + model.once_fee! + "%"
        onceLabel.textAlignment = .right
        onceLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        self.addSubview(onceLabel)
        
        interestLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(RATIO(maxNum: 10))
            make.centerY.equalTo(managementLabel)
            make.width.greaterThanOrEqualTo(10)
            make.height.greaterThanOrEqualTo(10)
        }
        
        onceLabel.snp.makeConstraints { (make) in
            make.width.greaterThanOrEqualTo(10)
            make.right.equalToSuperview().offset(RATIO(maxNum: -10))
            make.centerY.equalTo(managementLabel)
            make.height.greaterThanOrEqualTo(10)
        }
        
        managementLabel.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(RATIO_H(maxNum: 10))
            make.left.equalTo(interestLabel.snp.right).offset(RATIO(maxNum: 5))
            make.right.equalTo(onceLabel.snp.left).offset(RATIO(maxNum: -5))
            make.height.greaterThanOrEqualTo(10)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
